package com.menggudf.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.menggudf.model.IllnessModel;
import com.menggudf.model.ResultModel;
import com.menggudf.model.SymptomModel;
import com.menggudf.service.IllnessService;

@Controller
@RequestMapping("/newIllOper")
public class NewOperController {
    
    @Autowired
    private IllnessService illnessService;
    
    /**
     * 1,按性别/年龄  查找出对应的疾病
     * */
    @RequestMapping("/getIllnessBySexAndAge")
    @ResponseBody
    public Map<String, Object> getIllnessBySexAndAge(
            @RequestParam("sex") Integer sex,/*性别*/
            @RequestParam("age") Integer age/*年龄*/){
                return illnessService.getIllnessBySexAndAge(sex,age);
        
    }
     
    /**
     * 2,根据第一步查询出这个部位的相关病症（与这个疾病是相关联的）
     * */
    @RequestMapping("/getSymptomsByPart")
    @ResponseBody
    public Map<String, Object> getSymptomsByPart(
            @RequestParam("ids") String ids,
            @RequestParam("part") String part){
                return illnessService.getSymptomsByPart(ids,part);
    }
    
    /**
     * 3,根据病症symptom和疾病列表ids 
     * 获取病症的二级属性
     * */
    @RequestMapping("/getSymptoms")
    @ResponseBody
    public List<SymptomModel> getSymptoms(
            @RequestParam("ids") String ids,
            @RequestParam("symptom") String symptom){
        return illnessService.getSymptoms(ids,symptom);
        
    }
    
    /**
    * 4,按疾病ID和症状继续查询具体病(这里返回的ids是之前的id集合，不再更改，tp是数值)
    * */
   @RequestMapping("/getIllByIdAndsymptomsAndPart")
   @ResponseBody
   public ResultModel getIllByIdAndsymptomsAndPart(
           @RequestParam("ids") String ids,//当前所有id
           @RequestParam(value="part",required=false) String part,//当前部位
           @RequestParam("isImportant") Integer isImportant,
           @RequestParam(value="symptom") String symptom,//当前选择病症
           @RequestParam(value="degree",required=false) String degree,
           @RequestParam(value="nature",required=false) String nature,
           @RequestParam(value="times",required=false) String times,
           
           @RequestParam(value="factor",required=false) String factor,
           
           @RequestParam(value="imgurl",required=false) String imgurl,
           @RequestParam(value="pastHistory",required=false) String pastHistory,
           @RequestParam(value="incentive",required=false) String incentive,
           @RequestParam(value="medicineHistory",required=false) String medicineHistory,
           
           @RequestParam(value="tp",required=false) Double tp){
       return illnessService.getIllByIdAndsymptomsAndPart(
               symptom,ids,degree,nature,times,imgurl,part,pastHistory,incentive,medicineHistory,isImportant,tp,factor);
   }
   
   /**
    * 5.根据ids获取疾病
    * */
   @RequestMapping("/getIllByIds")
   @ResponseBody
   public List<IllnessModel> getIllByIds(
           @RequestParam("ids") String ids){
       return illnessService.getillsByIds(ids);
       
   }
   
   /**
    * 6.模糊查找病症
    * */
   @RequestMapping("/getSympByLike")
   @ResponseBody
   public List<String> getSympByLike(
           @RequestParam("sympName") String symp){
       return illnessService.getSympByLike(symp);
       
   }
   
   /**
    * 6.获取常见症状
    * */
   @RequestMapping("/getCommonSymp")
   @ResponseBody
   public List<String> getCommonSymp(){
       return illnessService.getCommonSymp();
       
   }
    
/*    *//**
     * 2,根据第一步查询出这个部位的相关病症（与这个疾病是相关联的）
     * *//*
    @RequestMapping("getSymptomsByPart")
    @ResponseBody
    public Map<String, Object> getSymptomsByPart(
            @RequestParam("ids") String ids,
            @RequestParam("part") String part){
                return illnessService.getSymptomsByPart(ids,part);
    }
    
    *//**
     * 3,根据病症symptom和疾病列表ids 
     * 获取病症的二级属性
     * *//*
    @RequestMapping("getSymptoms")
    @ResponseBody
    public Map<String, Object> getSymptoms(
            @RequestParam("ids") String ids,
            @RequestParam("symptom") String symptom){
        return illnessService.getSymptoms(ids,symptom);
        
    }
    
    *//**
     * 4,按疾病ID和症状继续查询具体病
     * symptoms为之前已经搜索过的字段
     * 得到的结果是这个部位的病症
     * *//*
    @RequestMapping("getIllByIdAndsymptomsAndPart")
    @ResponseBody
    public Map<String, Object> getIllByIdAndsymptomsAndPart(
            @RequestParam("ids") String ids,//当前所有id
            @RequestParam(value="symptoms") String symptoms,//当前已使用过的病症
            @RequestParam("part") String part,//当前部位
            @RequestParam("parts") String parts,//当前已使用的部位
            
            @RequestParam(value="symptom",required=false) String symptom,//当前选择病症
            @RequestParam(value="sup",required=false) Integer sup,
            @RequestParam(value="sdown",required=false) Integer sdown,
            @RequestParam(value="degree",required=false) String degree,
            @RequestParam(value="nature",required=false) String nature,
            @RequestParam(value="times",required=false) String times,
            @RequestParam(value="imgurl",required=false) String imgurl
            
            ){
        return illnessService.getIllByIdAndsymptomsAndPart(
                symptom,symptoms,ids,sup,sdown,degree,nature,times,imgurl,part,parts);
    }
    

    @RequestMapping("getIllByIdAndPart")
    @ResponseBody
    public Map<String, Object> getIllByIdAndPart(
            @RequestParam("ids") String ids,//当前所有id
            @RequestParam(value="symptoms") String symptoms,//当前已使用过的病症
            @RequestParam("part") String part,//当前部位
            @RequestParam("parts") String parts//当前已使用的部位
            ){
        return illnessService.getIllByIdAndPart(
                symptoms,ids,part,parts);
    }
    
    *//**
     * 4,按疾病ID和症状继续查询具体病
     * 判断是否有这个病症
     * *//*
    @RequestMapping("hasIllByIdAndsymptoms")
    @ResponseBody
    public Map<String, Object> hasIllByIdAndsymptoms(
            @RequestParam("ids") String ids,//当前所有id
            @RequestParam("part") String part,//当前部位
            @RequestParam("parts") String parts,//当前部位
            
            @RequestParam("symptom") String symptom,//当前选择病症
            @RequestParam(value="sup",required=false) Integer sup,
            @RequestParam(value="sdown",required=false) Integer sdown,
            @RequestParam(value="degree",required=false) String degree,
            @RequestParam(value="nature",required=false) String nature,
            @RequestParam(value="times",required=false) String times,
            @RequestParam(value="imgurl",required=false) String imgurl
            
            ){
        return illnessService.hasIllByIdAndsymptoms(
                symptom,ids,sup,sdown,degree,nature,times,imgurl,part,parts);
        
    }
    
    *//**
     * 根据疾病id获取疾病
     * *//*
    @RequestMapping("getIll2ById")
    @ResponseBody
    public Illness2Model getIll2ById(
            @RequestParam("id") String id){
        return illnessService.getIllness2ById(id);
        
    }
    
    *//**
     * 获取ids的辅助检查
     * *//*
    @RequestMapping("getExamByillList")
    @ResponseBody
    public List<String> getExamByillList(
            @RequestParam("ids") String ids){
                return illnessService.getExamByillList(ids);
        
    }*/

}
